
package com.tool.btn;

import com.tool.pet.PetProperty;
import com.tool.role.RoleData;
import com.tool.tcpimg.UIUtils;
import com.updateNew.MyIsif;

import come.tool.JDialog.TiShiUtil;

import java.awt.Color;
import java.awt.Font;
import java.awt.event.MouseEvent;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

import org.come.Frame.OptionsJframe;
import org.come.Frame.PartnerJframe;
import org.come.Frame.ZhuFrame;
import org.come.Jpanel.PartnerMainJpanel;
import org.come.Jpanel.PartnerSkillJpanel;
import org.come.Jpanel.PartnerTeamJpanel;
import org.come.Jpanel.ZhuJpanel;
import org.come.entity.Pal;
import org.come.model.PalData;
import org.come.socket.Agreement;
import org.come.socket.SendMessageUntil;
import org.come.until.CutButtonImage;
import org.come.until.FormsManagement;
import org.come.until.UserMessUntil;
import org.come.until.Util;


public class PartnerBtn extends MoBanBtn {
    private int caozuo;
    private PartnerMainJpanel partnerMainJpanel;

    public PartnerBtn(String iconpath, int type, int caozuo, PartnerMainJpanel partnerMainJpanel) {
        super(iconpath, type);
        this.caozuo = caozuo;
        this.partnerMainJpanel = partnerMainJpanel;
    }

    public PartnerBtn(String iconpath, int type, Color[] colors, Font font, String text, int caozuo) {
        super(iconpath, type, colors);
        this.setText(text);
        this.setFont(font);
        this.setVerticalTextPosition(0);
        this.setHorizontalTextPosition(0);
        this.caozuo = caozuo;
    }


    @Override
    public void chooseyes() {
    }

    @Override
    public void chooseno() {
    }

    @Override
    public void nochoose(MouseEvent e) {
        String style = MyIsif.getStyle();
        if ("水墨UI".equals(style)) {
            try {
                if (caozuo == 1) {
                    partnerMainJpanel.getBtnTeam().setIcons(CutButtonImage.cuts("skin/8100226/newbutton/K78.png"));
                    partnerMainJpanel.getBtnSkill().setIcons(CutButtonImage.cuts("skin/8100226/newbutton/K79.png"));
                    partnerMainJpanel.getBtnEquip().setIcons(CutButtonImage.cuts("skin/8100226/newbutton/K81.png"));
                    partnerMainJpanel.getPartnerCardJpanel().getCardLayout()
                            .show(partnerMainJpanel.getPartnerCardJpanel(), "team");

                } else if (caozuo == 2) {
                    partnerMainJpanel.getBtnTeam().setIcons(CutButtonImage.cuts("skin/8100226/newbutton/K77.png"));
                    partnerMainJpanel.getBtnSkill().setIcons(CutButtonImage.cuts("skin/8100226/newbutton/K80.png"));
                    partnerMainJpanel.getBtnEquip().setIcons(CutButtonImage.cuts("skin/8100226/newbutton/K81.png"));
                    partnerMainJpanel.getPartnerCardJpanel().getCardLayout()
                            .show(partnerMainJpanel.getPartnerCardJpanel(), "skill");

                } else if (caozuo == 3) {
                    partnerMainJpanel.getBtnTeam().setIcons(CutButtonImage.cuts("skin/8100226/newbutton/K77.png"));
                    partnerMainJpanel.getBtnSkill().setIcons(CutButtonImage.cuts("skin/8100226/newbutton/K79.png"));
                    partnerMainJpanel.getBtnEquip().setIcons(CutButtonImage.cuts("skin/8100226/newbutton/K82.png"));
                    partnerMainJpanel.getPartnerCardJpanel().getCardLayout()
                            .show(partnerMainJpanel.getPartnerCardJpanel(), "equip");

                } else if (caozuo == 4) {// 参战
                    if ("参战".equals(getText())) {
                        if (PartnerJframe.getPartnerJframe().getPartnerMainJpanel().getPalDataChooseId() < 0) {
                            return;
                        }
                        PartnerTeamJpanel partnerTeamJpanel = PartnerJframe.getPartnerJframe().getPartnerMainJpanel()
                                .getPartnerCardJpanel().getPartnerTeamJpanel();
                        if (partnerTeamJpanel.hideBtnArr()) {
                            return;
                        }
                        PartnerBtn[] btnArrAck = partnerTeamJpanel.getBtnArrAck();
                        String[] btnArrStr = partnerTeamJpanel.getBtnArrStr();
                        for (int i = 0; i < btnArrAck.length; i++) {
                            btnArrAck[3 - i].setText(btnArrStr[i]);
                        }
                        partnerTeamJpanel.showBtnArr(true);
                    } else if ("激活".equals(getText())) {
                        activatePal();
                    } else if ("调整".equals(getText())) {
                        if (PartnerJframe.getPartnerJframe().getPartnerMainJpanel().getPalDataChooseId() < 0) {
                            return;
                        }
                        PartnerMainJpanel partnerMainJpanel = PartnerJframe.getPartnerJframe().getPartnerMainJpanel();
                        PartnerTeamJpanel partnerTeamJpanel = partnerMainJpanel.getPartnerCardJpanel()
                                .getPartnerTeamJpanel();
                        if (partnerTeamJpanel.hideBtnArr()) {
                            return;
                        }
                        PartnerBtn[] btnArrAck = partnerTeamJpanel.getBtnArrAck();
                        String[] btnArrStr = partnerTeamJpanel.getBtnArrStr();
                        String pals = RoleData.getRoleData().getLoginResult().getPals();
                        if (pals != null) {
                            int num = 0;
                            String[] palsArr = pals.split("\\|");
                            for (int i = 0; i < palsArr.length; i++) {
                                if (palsArr[i].equals(partnerMainJpanel.pidGetPal(partnerMainJpanel.getPalDataChooseId())
                                        .getId() + "")) {
                                    num = i;
                                }
                            }
                            int sx = 0;
                            for (int i = 0; i < btnArrAck.length; i++) {
                                if (num == i) {
                                    continue;
                                }
                                btnArrAck[3 - sx].setText(btnArrStr[i]);
                                sx++;
                            }
                            btnArrAck[0].setText(btnArrStr[4]);
                        }
                        partnerTeamJpanel.showBtnArr(true);
                    }

                } else if (caozuo == 5) {// 抗性
                    PartnerMainJpanel mainJpanel = PartnerJframe.getPartnerJframe().getPartnerMainJpanel();
                    int chooseId = mainJpanel.getPalDataChooseId();
                    if (chooseId > 0) {
                        Pal pidGetPal = mainJpanel.pidGetPal(chooseId);
                        if (pidGetPal != null) {
                            PetProperty.ShowQl(pidGetPal);
                            FormsManagement.showForm(58);
                        } else {
                            // 还没有激活
                            ZhuFrame.getZhuJpanel().addPrompt2("你还没有激活当前伙伴");
                        }
                    } else {
                        // 没有选中
                        ZhuFrame.getZhuJpanel().addPrompt2("请先选中一个伙伴");
                    }
                } else if (caozuo == 6) {//
                    PartnerMainJpanel mainJpanel = PartnerJframe.getPartnerJframe().getPartnerMainJpanel();
                    int chooseId = mainJpanel.getPalDataChooseId();
                    if (chooseId > 0) {
                        Pal pidGetPal = mainJpanel.pidGetPal(chooseId);
                        if (pidGetPal != null) {
                            if (PartnerSkillJpanel.AIdataList != null) {
                                pidGetPal.setPalSkillAI(PartnerSkillJpanel.AIdataList);
                                String skills = "";
                                for (String v : PartnerSkillJpanel.AIdataList) {
                                    skills = skills + v + ",";
                                }
                                String sendmes = Agreement.getAgreement().userpalAgreement(pidGetPal.getId() + "|addSkillAI|" + skills);
                                SendMessageUntil.toServer(sendmes);
                                ZhuFrame.getZhuJpanel().addPrompt2("方案已保存！");
                            } else {
                                ZhuFrame.getZhuJpanel().addPrompt2("这个伙伴还没有设置方案！");
                            }
                        } else {
                            // 还没有激活
                            ZhuFrame.getZhuJpanel().addPrompt2("你还没有激活当前伙伴");
                        }
                    } else {
                        // 没有选中
                        ZhuFrame.getZhuJpanel().addPrompt2("请先选中一个伙伴");
                    }
                } else if (caozuo == 7) {// 抗性
                    PartnerMainJpanel mainJpanel = PartnerJframe.getPartnerJframe().getPartnerMainJpanel();
                    int chooseId = mainJpanel.getPalDataChooseId();
                    if (chooseId > 0) {
                        Pal pidGetPal = mainJpanel.pidGetPal(chooseId);
                        if (pidGetPal != null) {
                            if (PartnerSkillJpanel.AIdataList != null && pidGetPal.getPalSkillAI() != null) {
                                PartnerSkillJpanel.AIdataList = new ArrayList<>();
                                for (int i = 0; i < 7; i++) {
                                    PartnerSkillJpanel.labSkill[i].setText("第" + (i + 1) + "回合：");
                                    PartnerSkillJpanel.AIdataList.add("");
                                }
                                pidGetPal.setPalSkillAI(null);
                                ZhuFrame.getZhuJpanel().addPrompt2("方案已清空");
                                String sendmes = Agreement.getAgreement().userpalAgreement(pidGetPal.getId() + "|deleteSkillAI");
                                SendMessageUntil.toServer(sendmes);
                            } else {
                                ZhuFrame.getZhuJpanel().addPrompt2("该伙伴还没有施法方案");
                            }
                        } else {
                            // 还没有激活
                            ZhuFrame.getZhuJpanel().addPrompt2("你还没有激活当前伙伴");
                        }
                    } else {
                        // 没有选中
                        ZhuFrame.getZhuJpanel().addPrompt2("请先选中一个伙伴");
                    }
                } else if (caozuo == 8) {// 突破
                    ZhuFrame.getZhuJpanel().addPrompt2("该道具已经失效");
                    return;
//                    PartnerMainJpanel mainJpanel = PartnerJframe.getPartnerJframe().getPartnerMainJpanel();
//                    int chooseId = mainJpanel.getPalDataChooseId();
//                    PartnerEquipJpanel equipJpanel = mainJpanel.getPartnerCardJpanel().getPartnerEquipJpanel();
//                    if (chooseId < 0) {
//                        return;
//                    }
//                    Pal pidGetPal = mainJpanel.pidGetPal(chooseId);
//                    if (pidGetPal != null) {
//                        int breakLevel = equipJpanel.isBreakLevel(pidGetPal.getLvl());
//                        long palExp = PartnerJframe.getPartnerJframe().getPartnerMainJpanel().getPartnerCardJpanel()
//                                .getPartnerEquipJpanel().palExp(pidGetPal.getLvl());
//                        if (palExp > pidGetPal.getExp()) {
//                            ZhuFrame.getZhuJpanel().addPrompt2("经验没有升满");
//                            return;
//                        }
//                        if (breakLevel < 0) {
//                            ZhuFrame.getZhuJpanel().addPrompt2("等级没有抵达突破要求");
//                            return;
//                        }
//                        StringBuffer buffer = new StringBuffer();
//                        buffer.append("#W突破#G");
//                        buffer.append(pidGetPal.getLvl());
//                        buffer.append("#W级需要#R");
//                        buffer.append(breakLevel);
//                        buffer.append("#W个等级突破丹。是否突破?");
//                        OptionsJframe.getOptionsJframe().getOptionsJpanel()
//                                .showBox(TiShiUtil.PalKey, pidGetPal, buffer.toString());
//                    } else {
//                        // 还没有激活
//                        ZhuFrame.getZhuJpanel().addPrompt2("你还没有激活当前伙伴");
//                    }
                } else if (caozuo == 9) {
                    ZhuJpanel.setUseGoodsType(0);
                    FormsManagement.showForm(2);
                } else if (caozuo == 10) {
                    PartnerMainJpanel mainJpanel = PartnerJframe.getPartnerJframe().getPartnerMainJpanel();
                    String[] btnArrStr = mainJpanel.getPartnerCardJpanel().getPartnerTeamJpanel().getBtnArrStr();
                    List<Pal> pals = null;
                    if (btnArrStr[0].equals(getText())) {
                        pals = changeLogignResultPals(1, mainJpanel.getPalDataChooseId(), mainJpanel);
                    } else if (btnArrStr[1].equals(getText())) {
                        pals = changeLogignResultPals(2, mainJpanel.getPalDataChooseId(), mainJpanel);
                    } else if (btnArrStr[2].equals(getText())) {
                        pals = changeLogignResultPals(3, mainJpanel.getPalDataChooseId(), mainJpanel);
                    } else if (btnArrStr[3].equals(getText())) {
                        pals = changeLogignResultPals(4, mainJpanel.getPalDataChooseId(), mainJpanel);
                    } else if (btnArrStr[4].equals(getText())) {
                        pals = changeLogignResultPals(-1, mainJpanel.getPalDataChooseId(), mainJpanel);
                    }
                    mainJpanel.getPartnerCardJpanel().getPartnerTeamJpanel().hideBtnArr();
                    mainJpanel.refreshPals(pals);
                } else if (this.caozuo == 11) {
                    partnerMainJpanel = PartnerJframe.getPartnerJframe().getPartnerMainJpanel();
                    int chooseId = partnerMainJpanel.getPalDataChooseId();
                    if (chooseId > 0) {
                        Pal pidGetPal = partnerMainJpanel.pidGetPal(chooseId);
                        if (pidGetPal.getSummoning() != null) {
                            if (pidGetPal.getSummoning() != null) {
                                ZhuFrame.getZhuJpanel().creatpettext(pidGetPal.getSummoning());
                            }
                        } else {
                            ZhuFrame.getZhuJpanel().addPrompt2("伙伴还没有召唤兽请前往召唤兽面板添加！");
                        }
                    } else {
                        ZhuFrame.getZhuJpanel().addPrompt2("请先选中一个伙伴");
                    }
                } else if (this.caozuo == 12) {
                    partnerMainJpanel = PartnerJframe.getPartnerJframe().getPartnerMainJpanel();
                    int chooseId = partnerMainJpanel.getPalDataChooseId();
                    if (chooseId > 0) {
                        Pal pidGetPal = partnerMainJpanel.pidGetPal(chooseId);
                        if (pidGetPal.getSummoning() != null) {
                            if (pidGetPal.getSummoning() != null) {
                                /**判断是否解锁*/
                                if (Util.isCanBuyOrno()) {
                                    return;
                                }
                                PalData palData = UserMessUntil.getPalData(pidGetPal.getpId());
                                String name = palData.getName();
                                OptionsJframe.getOptionsJframe().getOptionsJpanel().showBox(TiShiUtil.palGetPet, pidGetPal, "#W确定要将伙伴" + name + "的召唤兽:#G" + pidGetPal.getSummoning().getSummoningname() + "#W取回吗?");
                            }
                        } else {
                            ZhuFrame.getZhuJpanel().addPrompt2("伙伴还没有召唤兽！");
                        }
                    } else {
                        ZhuFrame.getZhuJpanel().addPrompt2("请先选中一个伙伴");
                    }
                } else if (this.caozuo == 13) {
                    partnerMainJpanel = PartnerJframe.getPartnerJframe().getPartnerMainJpanel();
                    int chooseId = partnerMainJpanel.getPalDataChooseId();
                    if (chooseId > 0) {
                        Pal pidGetPal = partnerMainJpanel.pidGetPal(chooseId);
                        if (pidGetPal.getLingbao() != null) {
                            if (pidGetPal.getLingbao() != null) {
                                ZhuFrame.getZhuJpanel().creatlingtext(pidGetPal.getLingbao());
                            }
                        } else {
                            ZhuFrame.getZhuJpanel().addPrompt2("伙伴还没有装备灵宝请前往灵宝面板添加！");
                        }
                    } else {
                        ZhuFrame.getZhuJpanel().addPrompt2("请先选中一个伙伴");
                    }
                } else if (this.caozuo == 14) {
                    partnerMainJpanel = PartnerJframe.getPartnerJframe().getPartnerMainJpanel();
                    int chooseId = partnerMainJpanel.getPalDataChooseId();
                    if (chooseId > 0) {
                        Pal pidGetPal = partnerMainJpanel.pidGetPal(chooseId);
                        if (pidGetPal.getLingbao() != null) {
                            if (pidGetPal.getLingbao() != null) {
                                /**判断是否解锁*/
                                if (Util.isCanBuyOrno()) {
                                    return;
                                }
                                PalData palData = UserMessUntil.getPalData(pidGetPal.getpId());
                                String name = palData.getName();
                                OptionsJframe.getOptionsJframe().getOptionsJpanel().showBox(TiShiUtil.palGetLingbao, pidGetPal, "#W确定要将伙伴" + name + "的灵宝:#G" + pidGetPal.getLingbao().getBaoname() + "#W取回吗?");
                            }
                        } else {
                            ZhuFrame.getZhuJpanel().addPrompt2("伙伴还没有灵宝！");
                        }
                    } else {
                        ZhuFrame.getZhuJpanel().addPrompt2("请先选中一个伙伴");
                    }
                } else if (this.caozuo >= 2024) {
                    int ix = 0;
                    if (PartnerSkillJpanel.AIdataList != null) {
                        for (String s : PartnerSkillJpanel.AIdataList) {
                            if (s != null) {
                                ix++;
                            }
                        }
                    }
                    if (this.caozuo - 2024 > ix) {
                        ZhuFrame.getZhuJpanel().addPrompt2("请先设置上一个回合的技能");
                        return;
                    }
                    int ys = (this.caozuo - 2024) * 30;
                    PartnerSkillJpanel.x = this.caozuo - 2024;
                    for (int i = 0; i < 3; i++) {
                        PartnerSkillJpanel.labSkillName[i].setFont(new Font("楷体", Font.BOLD, 17));
                        PartnerSkillJpanel.labSkillName[i].setForeground(UIUtils.COLOR_WHITE[0]);
                        PartnerSkillJpanel.labSkillName[i].setBounds(80, ys + i * 22, 72, 25);
                        PartnerSkillJpanel.labSkillName[i].setVisible(true);
                    }
                    if (e.getButton() == 3) {
                        for (int i = 0; i < 3; i++) {
                            PartnerSkillJpanel.labSkillName[i].setVisible(false);
                        }
                    }
                }
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        } else {
            try {
                if (this.caozuo == 1) {
                    this.partnerMainJpanel.getBtnTeam().setIcons(CutButtonImage.cuts("img/xy2uiimg/B229.png"));
                    this.partnerMainJpanel.getBtnSkill().setIcons(CutButtonImage.cuts("img/xy2uiimg/B232.png"));
                    this.partnerMainJpanel.getBtnEquip().setIcons(CutButtonImage.cuts("img/xy2uiimg/B234.png"));
                    this.partnerMainJpanel.getPartnerCardJpanel().getCardLayout().show(this.partnerMainJpanel.getPartnerCardJpanel(), "team");
                } else if (this.caozuo == 2) {
                    this.partnerMainJpanel.getBtnTeam().setIcons(CutButtonImage.cuts("img/xy2uiimg/B230.png"));
                    this.partnerMainJpanel.getBtnSkill().setIcons(CutButtonImage.cuts("img/xy2uiimg/B231.png"));
                    this.partnerMainJpanel.getBtnEquip().setIcons(CutButtonImage.cuts("img/xy2uiimg/B234.png"));
                    this.partnerMainJpanel.getPartnerCardJpanel().getCardLayout().show(this.partnerMainJpanel.getPartnerCardJpanel(), "skill");
                } else if (this.caozuo == 3) {
                    this.partnerMainJpanel.getBtnTeam().setIcons(CutButtonImage.cuts("img/xy2uiimg/B230.png"));
                    this.partnerMainJpanel.getBtnSkill().setIcons(CutButtonImage.cuts("img/xy2uiimg/B232.png"));
                    this.partnerMainJpanel.getBtnEquip().setIcons(CutButtonImage.cuts("img/xy2uiimg/B233.png"));
                    this.partnerMainJpanel.getPartnerCardJpanel().getCardLayout().show(this.partnerMainJpanel.getPartnerCardJpanel(), "equip");

                } else if (caozuo == 4) {// 参战
                    if ("参战".equals(getText())) {
                        if (PartnerJframe.getPartnerJframe().getPartnerMainJpanel().getPalDataChooseId() < 0) {
                            return;
                        }
                        PartnerTeamJpanel partnerTeamJpanel = PartnerJframe.getPartnerJframe().getPartnerMainJpanel()
                                .getPartnerCardJpanel().getPartnerTeamJpanel();
                        if (partnerTeamJpanel.hideBtnArr()) {
                            return;
                        }
                        PartnerBtn[] btnArrAck = partnerTeamJpanel.getBtnArrAck();
                        String[] btnArrStr = partnerTeamJpanel.getBtnArrStr();
                        for (int i = 0; i < btnArrAck.length; i++) {
                            btnArrAck[3 - i].setText(btnArrStr[i]);
                        }
                        partnerTeamJpanel.showBtnArr(true);
                    } else if ("激活".equals(getText())) {
                        activatePal();
                    } else if ("调整".equals(getText())) {
                        if (PartnerJframe.getPartnerJframe().getPartnerMainJpanel().getPalDataChooseId() < 0) {
                            return;
                        }
                        PartnerMainJpanel partnerMainJpanel = PartnerJframe.getPartnerJframe().getPartnerMainJpanel();
                        PartnerTeamJpanel partnerTeamJpanel = partnerMainJpanel.getPartnerCardJpanel()
                                .getPartnerTeamJpanel();
                        if (partnerTeamJpanel.hideBtnArr()) {
                            return;
                        }
                        PartnerBtn[] btnArrAck = partnerTeamJpanel.getBtnArrAck();
                        String[] btnArrStr = partnerTeamJpanel.getBtnArrStr();
                        String pals = RoleData.getRoleData().getLoginResult().getPals();
                        if (pals != null) {
                            int num = 0;
                            String[] palsArr = pals.split("\\|");
                            for (int i = 0; i < palsArr.length; i++) {
                                if (palsArr[i].equals(partnerMainJpanel.pidGetPal(partnerMainJpanel.getPalDataChooseId())
                                        .getId() + "")) {
                                    num = i;
                                }
                            }
                            int sx = 0;
                            for (int i = 0; i < btnArrAck.length; i++) {
                                if (num == i) {
                                    continue;
                                }
                                btnArrAck[3 - sx].setText(btnArrStr[i]);
                                sx++;
                            }
                            btnArrAck[0].setText(btnArrStr[4]);
                        }
                        partnerTeamJpanel.showBtnArr(true);
                    }

                } else if (caozuo == 5) {// 抗性
                    PartnerMainJpanel mainJpanel = PartnerJframe.getPartnerJframe().getPartnerMainJpanel();
                    int chooseId = mainJpanel.getPalDataChooseId();
                    if (chooseId > 0) {
                        Pal pidGetPal = mainJpanel.pidGetPal(chooseId);
                        if (pidGetPal != null) {
                            PetProperty.ShowQl(pidGetPal);
                            FormsManagement.showForm(58);
                        } else {
                            // 还没有激活
                            ZhuFrame.getZhuJpanel().addPrompt2("你还没有激活当前伙伴");
                        }
                    } else {
                        // 没有选中
                        ZhuFrame.getZhuJpanel().addPrompt2("请先选中一个伙伴");
                    }
                } else if (caozuo == 6) {//
                    PartnerMainJpanel mainJpanel = PartnerJframe.getPartnerJframe().getPartnerMainJpanel();
                    int chooseId = mainJpanel.getPalDataChooseId();
                    if (chooseId > 0) {
                        Pal pidGetPal = mainJpanel.pidGetPal(chooseId);
                        if (pidGetPal != null) {
                            if (PartnerSkillJpanel.AIdataList != null) {
                                pidGetPal.setPalSkillAI(PartnerSkillJpanel.AIdataList);
                                String skills = "";
                                for (String v : PartnerSkillJpanel.AIdataList) {
                                    skills = skills + v + ",";
                                }
                                String sendmes = Agreement.getAgreement().userpalAgreement(pidGetPal.getId() + "|addSkillAI|" + skills);
                                SendMessageUntil.toServer(sendmes);
                                ZhuFrame.getZhuJpanel().addPrompt2("方案已保存！");
                            } else {
                                ZhuFrame.getZhuJpanel().addPrompt2("这个伙伴还没有设置方案！");
                            }
                        } else {
                            // 还没有激活
                            ZhuFrame.getZhuJpanel().addPrompt2("你还没有激活当前伙伴");
                        }
                    } else {
                        // 没有选中
                        ZhuFrame.getZhuJpanel().addPrompt2("请先选中一个伙伴");
                    }
                } else if (caozuo == 7) {// 抗性
                    PartnerMainJpanel mainJpanel = PartnerJframe.getPartnerJframe().getPartnerMainJpanel();
                    int chooseId = mainJpanel.getPalDataChooseId();
                    if (chooseId > 0) {
                        Pal pidGetPal = mainJpanel.pidGetPal(chooseId);
                        if (pidGetPal != null) {
                            if (PartnerSkillJpanel.AIdataList != null && pidGetPal.getPalSkillAI() != null) {
                                PartnerSkillJpanel.AIdataList = new ArrayList<>();
                                for (int i = 0; i < 7; i++) {
                                    PartnerSkillJpanel.labSkill[i].setText("第" + (i + 1) + "回合：");
                                    PartnerSkillJpanel.AIdataList.add("");
                                }
                                pidGetPal.setPalSkillAI(null);
                                ZhuFrame.getZhuJpanel().addPrompt2("方案已清空");
                                String sendmes = Agreement.getAgreement().userpalAgreement(pidGetPal.getId() + "|deleteSkillAI");
                                SendMessageUntil.toServer(sendmes);
                            } else {
                                ZhuFrame.getZhuJpanel().addPrompt2("该伙伴还没有施法方案");
                            }
                        } else {
                            // 还没有激活
                            ZhuFrame.getZhuJpanel().addPrompt2("你还没有激活当前伙伴");
                        }
                    } else {
                        // 没有选中
                        ZhuFrame.getZhuJpanel().addPrompt2("请先选中一个伙伴");
                    }
                } else if (caozuo == 8) {// 突破
                    ZhuFrame.getZhuJpanel().addPrompt2("该道具已经失效");
                    return;
//                    PartnerMainJpanel mainJpanel = PartnerJframe.getPartnerJframe().getPartnerMainJpanel();
//                    int chooseId = mainJpanel.getPalDataChooseId();
//                    PartnerEquipJpanel equipJpanel = mainJpanel.getPartnerCardJpanel().getPartnerEquipJpanel();
//                    if (chooseId < 0) {
//                        return;
//                    }
//                    Pal pidGetPal = mainJpanel.pidGetPal(chooseId);
//                    if (pidGetPal != null) {
//                        int breakLevel = equipJpanel.isBreakLevel(pidGetPal.getLvl());
//                        long palExp = PartnerJframe.getPartnerJframe().getPartnerMainJpanel().getPartnerCardJpanel()
//                                .getPartnerEquipJpanel().palExp(pidGetPal.getLvl());
//                        if (palExp > pidGetPal.getExp()) {
//                            ZhuFrame.getZhuJpanel().addPrompt2("经验没有升满");
//                            return;
//                        }
//                        if (breakLevel < 0) {
//                            ZhuFrame.getZhuJpanel().addPrompt2("等级没有抵达突破要求");
//                            return;
//                        }
//                        StringBuffer buffer = new StringBuffer();
//                        buffer.append("#W突破#G");
//                        buffer.append(pidGetPal.getLvl());
//                        buffer.append("#W级需要#R");
//                        buffer.append(breakLevel);
//                        buffer.append("#W个等级突破丹。是否突破?");
//                        OptionsJframe.getOptionsJframe().getOptionsJpanel()
//                                .showBox(TiShiUtil.PalKey, pidGetPal, buffer.toString());
//                    } else {
//                        // 还没有激活
//                        ZhuFrame.getZhuJpanel().addPrompt2("你还没有激活当前伙伴");
//                    }
                } else if (caozuo == 9) {
                    ZhuJpanel.setUseGoodsType(0);
                    FormsManagement.showForm(2);
                } else if (caozuo == 10) {
                    PartnerMainJpanel mainJpanel = PartnerJframe.getPartnerJframe().getPartnerMainJpanel();
                    String[] btnArrStr = mainJpanel.getPartnerCardJpanel().getPartnerTeamJpanel().getBtnArrStr();
                    List<Pal> pals = null;
                    if (btnArrStr[0].equals(getText())) {
                        pals = changeLogignResultPals(1, mainJpanel.getPalDataChooseId(), mainJpanel);
                    } else if (btnArrStr[1].equals(getText())) {
                        pals = changeLogignResultPals(2, mainJpanel.getPalDataChooseId(), mainJpanel);
                    } else if (btnArrStr[2].equals(getText())) {
                        pals = changeLogignResultPals(3, mainJpanel.getPalDataChooseId(), mainJpanel);
                    } else if (btnArrStr[3].equals(getText())) {
                        pals = changeLogignResultPals(4, mainJpanel.getPalDataChooseId(), mainJpanel);
                    } else if (btnArrStr[4].equals(getText())) {
                        pals = changeLogignResultPals(-1, mainJpanel.getPalDataChooseId(), mainJpanel);
                    }
                    mainJpanel.getPartnerCardJpanel().getPartnerTeamJpanel().hideBtnArr();
                    mainJpanel.refreshPals(pals);
                } else if (this.caozuo == 11) {
                    partnerMainJpanel = PartnerJframe.getPartnerJframe().getPartnerMainJpanel();
                    int chooseId = partnerMainJpanel.getPalDataChooseId();
                    if (chooseId > 0) {
                        Pal pidGetPal = partnerMainJpanel.pidGetPal(chooseId);
                        if (pidGetPal.getSummoning() != null) {
                            if (pidGetPal.getSummoning() != null) {
                                ZhuFrame.getZhuJpanel().creatpettext(pidGetPal.getSummoning());
                            }
                        } else {
                            ZhuFrame.getZhuJpanel().addPrompt2("伙伴还没有召唤兽请前往召唤兽面板添加！");
                        }
                    } else {
                        ZhuFrame.getZhuJpanel().addPrompt2("请先选中一个伙伴");
                    }
                } else if (this.caozuo == 12) {
                    partnerMainJpanel = PartnerJframe.getPartnerJframe().getPartnerMainJpanel();
                    int chooseId = partnerMainJpanel.getPalDataChooseId();
                    if (chooseId > 0) {
                        Pal pidGetPal = partnerMainJpanel.pidGetPal(chooseId);
                        if (pidGetPal.getSummoning() != null) {
                            if (pidGetPal.getSummoning() != null) {
                                /**判断是否解锁*/
                                if (Util.isCanBuyOrno()) {
                                    return;
                                }
                                PalData palData = UserMessUntil.getPalData(pidGetPal.getpId());
                                String name = palData.getName();
                                OptionsJframe.getOptionsJframe().getOptionsJpanel().showBox(TiShiUtil.palGetPet, pidGetPal, "#W确定要将伙伴" + name + "的召唤兽:#G" + pidGetPal.getSummoning().getSummoningname() + "#W取回吗?");
                            }
                        } else {
                            ZhuFrame.getZhuJpanel().addPrompt2("伙伴还没有召唤兽！");
                        }
                    } else {
                        ZhuFrame.getZhuJpanel().addPrompt2("请先选中一个伙伴");
                    }
                } else if (this.caozuo == 13) {
                    partnerMainJpanel = PartnerJframe.getPartnerJframe().getPartnerMainJpanel();
                    int chooseId = partnerMainJpanel.getPalDataChooseId();
                    if (chooseId > 0) {
                        Pal pidGetPal = partnerMainJpanel.pidGetPal(chooseId);
                        if (pidGetPal.getLingbao() != null) {
                            if (pidGetPal.getLingbao() != null) {
                                ZhuFrame.getZhuJpanel().creatlingtext(pidGetPal.getLingbao());
                            }
                        } else {
                            ZhuFrame.getZhuJpanel().addPrompt2("伙伴还没有装备灵宝请前往灵宝面板添加！");
                        }
                    } else {
                        ZhuFrame.getZhuJpanel().addPrompt2("请先选中一个伙伴");
                    }
                } else if (this.caozuo == 14) {
                    partnerMainJpanel = PartnerJframe.getPartnerJframe().getPartnerMainJpanel();
                    int chooseId = partnerMainJpanel.getPalDataChooseId();
                    if (chooseId > 0) {
                        Pal pidGetPal = partnerMainJpanel.pidGetPal(chooseId);
                        if (pidGetPal.getLingbao() != null) {
                            if (pidGetPal.getLingbao() != null) {
                                /**判断是否解锁*/
                                if (Util.isCanBuyOrno()) {
                                    return;
                                }
                                PalData palData = UserMessUntil.getPalData(pidGetPal.getpId());
                                String name = palData.getName();
                                OptionsJframe.getOptionsJframe().getOptionsJpanel().showBox(TiShiUtil.palGetLingbao, pidGetPal, "#W确定要将伙伴" + name + "的灵宝:#G" + pidGetPal.getLingbao().getBaoname() + "#W取回吗?");
                            }
                        } else {
                            ZhuFrame.getZhuJpanel().addPrompt2("伙伴还没有灵宝！");
                        }
                    } else {
                        ZhuFrame.getZhuJpanel().addPrompt2("请先选中一个伙伴");
                    }
                } else if (this.caozuo >= 2024) {
                    int ix = 0;
                    if (PartnerSkillJpanel.AIdataList != null) {
                        for (String s : PartnerSkillJpanel.AIdataList) {
                            if (s != null) {
                                ix++;
                            }
                        }
                    }
                    if (this.caozuo - 2024 > ix) {
                        ZhuFrame.getZhuJpanel().addPrompt2("请先设置上一个回合的技能");
                        return;
                    }
                    int ys = (this.caozuo - 2024) * 30;
                    PartnerSkillJpanel.x = this.caozuo - 2024;
                    for (int i = 0; i < 3; i++) {
                        PartnerSkillJpanel.labSkillName[i].setFont(new Font("楷体", Font.BOLD, 17));
                        PartnerSkillJpanel.labSkillName[i].setForeground(UIUtils.COLOR_WHITE[0]);
                        PartnerSkillJpanel.labSkillName[i].setBounds(80, ys + i * 22, 72, 25);
                        PartnerSkillJpanel.labSkillName[i].setVisible(true);
                    }
                    if (e.getButton() == 3) {
                        for (int i = 0; i < 3; i++) {
                            PartnerSkillJpanel.labSkillName[i].setVisible(false);
                        }
                    }
                }
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    }

    public List<Pal> changeLogignResultPals(int type, int pid, PartnerMainJpanel mainJpanel) {
        List<Pal> palsList = new ArrayList();
        String pals = RoleData.getRoleData().getLoginResult().getPals();
        StringBuffer mesBuf = new StringBuffer();
        mesBuf.append("P");
        Pal pidGetPal = mainJpanel.pidGetPal(pid);
        BigDecimal id = pidGetPal.getId();
        mesBuf.append(id);
        palsList.add(mainJpanel.idGetPal(id));
        if (pals != null && !"".equals(pals)) {
            StringBuffer buffer = new StringBuffer();
            String[] palsArr = pals.split("\\|");
            if (palsArr.length < type) {
                for (int i = 0; i < palsArr.length; ++i) {
                    if (!palsArr[i].equals("" + id)) {
                        if (buffer.length() != 0) {
                            buffer.append("|");
                        }

                        buffer.append(palsArr[i]);
                        palsList.add(mainJpanel.idGetPal(new BigDecimal(palsArr[i])));
                    }
                }

                buffer.append("|");
                buffer.append(id);
            } else {
                String lastPid = type > 0 ? palsArr[type - 1] : null;
                if (lastPid != null) {
                    palsList.add(mainJpanel.idGetPal(new BigDecimal(lastPid)));
                }

                mesBuf.append("|");
                mesBuf.append(type > 0 ? type - 1 : -1);

                int i;
                for (i = 0; i < palsArr.length; ++i) {
                    if (palsArr[i].equals("" + id)) {
                        palsArr[i] = lastPid;
                    } else if (type - 1 == i) {
                        palsArr[i] = "" + id;
                    }
                }

                for (i = 0; i < palsArr.length; ++i) {
                    if (palsArr[i] != null && palsArr[i] != "" && !palsArr[i].isEmpty()) {
                        if (buffer.length() != 0) {
                            buffer.append("|");
                        }

                        buffer.append(palsArr[i]);
                        palsList.add(mainJpanel.idGetPal(new BigDecimal(palsArr[i])));
                    }
                }
            }

            RoleData.getRoleData().getLoginResult().setPals(buffer.toString());
        } else {
            RoleData.getRoleData().getLoginResult().setPals("" + id);
        }

        String sendmes = Agreement.getAgreement().userpalAgreement(mesBuf.toString());
        SendMessageUntil.toServer(sendmes);
        return palsList;
    }

    public void activatePal() {
        PartnerMainJpanel mainJpanel = PartnerJframe.getPartnerJframe().getPartnerMainJpanel();
        int chooseId = mainJpanel.getPalDataChooseId();
        if (chooseId < 0) {
            ZhuFrame.getZhuJpanel().addPrompt2("请先选中一个伙伴");
        } else {
            PalData palData = UserMessUntil.getPalData(chooseId);
            if (palData == null) {
                ZhuFrame.getZhuJpanel().addPrompt2("请先选中一个伙伴");
            } else {
                String xh = palData.getXh();
                StringBuffer buffer = new StringBuffer();
                buffer.append("#W确定要激活#G");
                buffer.append(palData.getName());
                if (xh != null && !"".equals(xh)) {
                    buffer.append("#W吗?消耗:#R");
                    buffer.append(xh.substring(1, xh.length()));
                    if (xh.startsWith("D")) {
                        buffer.append("大话币#W。");
                    } else if (xh.startsWith("X")) {
                        buffer.append("仙玉#W。");
                    }
                } else {
                    buffer.append("吗?消耗:#R无消耗#W。");
                }

                OptionsJframe.getOptionsJframe().getOptionsJpanel().showBox(TiShiUtil.PalKey, palData, buffer.toString());
            }
        }
    }
}
